<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
<ol class="breadcrumb">
  <li><a href="<?php echo base_url('/index.php/inicio');?>">Início</a></li>
  <li><a href="<?php echo base_url('index.php/contatos/novo');?>">Contato</a></li>
  <li class="active">Consulta</li>
</ol>
		<!--<form class="form-horizontal" id="form" role="form" action="<?php echo base_url('index.php/contatos/editamassa');?>" method="POST">-->
		<form role="form" id="contatos">
			<fieldset>
				<legend>Consulta Contatos</legend>
				<table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
					<thead>
						<tr>
							<th>#</th>
							<th>Ramal</th>
							<th>Contato</th>
							<th>Secretaria</th>
							<th>Cargo</th>
							<th>E-mail</th>
							<th>Editar</th>
							<th>Excluir</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
				
				<!--<button type="submit" id="alterar" class="btn btn-primary btn-sm glyphicon glyphicon-minus"> Alterar Contato/ramal</button> -->
				
			
			<div class="form-group">
			<div class="input-group">
				<button type="submit" id="myButton" data-loading-text="Loading..." class="btn btn-danger ">Excluir contatos selecionados</button>
			</div>
			</div>
			</fieldset>
		</form>
		</div>
		<script type="text/javascript">
			$(document).ready(function(){
				$('#example').DataTable({
					"processing": true,
					"serverSide": true,
					"ajax": {
						"url": "<?php echo base_url('index.php/contatos/consultaContatosJson'); ?>"
					},
					"order": [[ 1, "asc" ]],
					"language": {
						"url": "<?php echo base_url('includes/js/Portuguese-Brasil.json'); ?>"
					},
					 "pagingType": "simple"
				});
			

				$('#contatos').validate({  
					rules: {  
						id: { required: true }
						
					},  
					messages: {  
						id: { required: 'Preencha o campo'}
					},
					submitHandler: function( form ){  
						var dados = $('#contatos').serialize();  
						//alert(dados);
						$.ajax({  
							type: "POST",  
							url: "<?php echo base_url('index.php/contatos/excluirSelecionados');?>",  
							data: dados,  
							success: function( data )  
							{  
								alert(data);
								window.location = "<?php echo base_url('index.php/contatos/consulta');?>";
								
							}  
						});  
						return false;  
					}
				});
			});
		</script>
</body>
</html>
